package mynote;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

//监听列表选择项改变
public class NoteListListener implements ListSelectionListener {
    private NoteFrame noteFrame;
    private JList<String> list;

    public NoteListListener(NoteFrame noteFrame, JList<String> list) {
        this.noteFrame = noteFrame;
        this.list = list;
    }

    @Override
    public void valueChanged(ListSelectionEvent e) {
        String val = list.getSelectedValue();
        if (val != null)
            noteFrame.getNote(val);
    }
}
